package com.wd.live.viewmodel;

import android.app.Application;

import androidx.annotation.NonNull;
import androidx.lifecycle.MutableLiveData;

import com.wd.live.base.BaseViewModel;
import com.wd.live.bean.QMBean;
import com.wd.live.model.HttpUtils;
import com.wd.live.model.SpUtils;

import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;

public class QianMingViewModel extends BaseViewModel {

    public QianMingViewModel(@NonNull Application application) {
        super(application);
    }

    MutableLiveData<QMBean> list=new MutableLiveData<>();
    String uid= SpUtils.getString("uid","");
    Integer userId = Integer.valueOf(uid);
    String sid=SpUtils.getString("sid","");
    public MutableLiveData<QMBean> getList(String count) {
        HttpUtils.getHttpUtils()
                .getApi()
                .QM(userId,sid,count)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Observer<QMBean>() {
                    @Override
                    public void onSubscribe(Disposable d) {

                    }

                    @Override
                    public void onNext(QMBean value) {
                        list.postValue(value);
                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onComplete() {

                    }
                });
        return list;
    }
}
